<%-- 
    Document   : signup
    Created on : Sep 20, 2011, 9:30:29 AM
    Author     : SAMMY
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<jsp:include page="/header.jsp"></jsp:include>
<form action="./users?action=edit<c:if test="${sessionScope.user.getRoleId() == 1}">&id=${user.getId()}</c:if>" method="post" name="edit_form" id="edit_form" onsubmit="return validate_edit(this)">
    <label for="name">Full Name:</label>
    <input type="text" name="name" value="${user.getName()}" id="name"/><br />

    <label for="password">Password:</label>
    <input type="password" name="password" value="" id="password"/><br />

    <label for="confirm_password">Password (again):</label>
    <input type="password" name="confirm_password" value="" id="confirm_password"/><br />

    <label for="email">Email:</label>
    <input type="text" name="email" value="${user.getEmail()}" id="email"/><br />

    <label for="location">Address:</label>
    <input type="text" name="address" value="${user.getAddress()}" id="address"/><br />

    <label for="location">City:</label>
    <select name="city" id="city">
        <c:forEach items="${cities}" var="city">selected
            <option<c:if test="${city.getName() == user.getCity()}"> selected</c:if> value="${city.getId()}">${city.getName()}</option>
        </c:forEach>
    </select><br/>

    <label for="phone">Phone:</label>
    <input type="text" name="phone" value="${user.getPhone()}" id="phone"/><br />

    <c:if test="${sessionScope.user.getRoleId() == 1}">
        <label for="role">Role:</label>
        <select name="role" id="role">
            <c:forEach items="${roles}" var="role">
                <option<c:if test="${user.getRoleId() == role.id}"> selected</c:if> value="${role.getId()}">${role.getName()}</option>
            </c:forEach>
        </select><br/>
    </c:if>

    <input type="submit" name="submit" id="submit" value="Save" />
</form>
<jsp:include page="/footer.jsp"></jsp:include>